/**
 * 
 */
package vl.scanfile.ulti;

import java.lang.reflect.Type;

import vl.scanfile.vo.FtpVO;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

/**
 * @author Chau
 *
 */
public class FtpVOSerializer implements JsonSerializer<TreeNode<FtpVO>>{
	public JsonElement serialize (TreeNode<FtpVO> src,
            Type typeOfSrc,
            JsonSerializationContext context)
	{
		Gson gson = new Gson ();

		JsonObject step = new JsonObject ();
		step.add ("children", gson.toJsonTree (src.getChildren()));
		step.add ("text",   gson.toJsonTree (src.getData().getText()));
		step.add ("type",   gson.toJsonTree (src.getData().getType()));
		
		return step;
	}
}
